package com.dmbjz.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping(path = "dmbjz")
public class HelloController {

    @Autowired
    private RedisTemplate redisTemplate;
    @RequestMapping(path = "index")
    public String index(){
        String name = SecurityContextHolder.getContext().getAuthentication().getName();

        String token = (String) redisTemplate.opsForValue().get("login" + name);//Redis中获取token

        return "Hello Security  token:"+token;
    }


}
